<div class="eject_con">
  <div id="warning" class="alert alert-error"></div>
  <form id="post_form" method="post" action="index.php?act=store_piao&op=add">
    <input type="hidden" name="form_submit" value="ok" />
    <dl>
      <dt>手机号/车牌号<?php echo $lang['nc_colon'];?></dt>
      <dd>
          <input class="text w200" type="text" name="mobile" id="mobile" value="" /><p class="hint">已注册用户</p>
          <input type="button" id="search" class="submit" value="查找"/>
      </dd>
    </dl>

    <dl>
      <dt><i class="required">*</i>会员姓名<?php echo $lang['nc_colon'];?></dt>
      <dd>
        <input type="hidden" name="member_id" id="member_id" />
        <input type="hidden" name="member_name" id="member_name" />
        <input class="text w200" type="text" name="member_truename" id="member_truename" value="" readonly />
      </dd>
    </dl>
    <dl>
      <dt>手机号码<?php echo $lang['nc_colon'];?></dt>
      <dd>
        <input class="text w200" type="text" name="member_mobile" id="member_mobile" value="" readonly  />
      </dd>
    </dl>
    <dl>
      <dt>发放信息<?php echo $lang['nc_colon'];?></dt>
      <dd>
        <!--textarea name="bus_info" rows="2" class="textarea w300"></textarea-->
         <div id="status_div"></div>
          <input type="hidden" id="pay_status" />
      </dd>
    </dl>
    <div class="bottom">
        <label class="submit-border"><input type="submit" class="submit" value="发放" /></label>
    </div>
  </form>
</div>
<script type="text/javascript">
$(function(){
   $("#search").click(function(){
       $.ajax({
           type:"GET",
           url:'<?php echo urlShop('store_piao', 'check_member_ajax');?>',
           async:false,
           dataType: "json",
           data:{keyword: $('#mobile').val()},
           success: function(data){
               if(data) {
                  $('#member_id').val(data.member_id);
                  $('#member_name').val(data.member_name);
                  $('#member_truename').val(data.member_truename);
                  if(!data.member_truename && data.member_nickname){
                      $('#member_truename').val(data.member_nickname);
                  }
                  $('#member_mobile').val(data.member_mobile);
                  status_str = data.member_piao==1 ? "已发放":"未发放";
                  $("#status_div").html(status_str);
                  $("#pay_status").val(data.member_piao);
                   if(!data.member_id && !data.member_piao){
                       status_str = '该会员尚未注册';
                       $("#status_div").html(status_str);
                       $("#pay_status").val('2');
                   }
               }
           }
       });
   });

    $('#post_form').validate({
        errorLabelContainer: $('#warning'),
        invalidHandler: function(form, validator) {
            $('#warning').show();
        },
    	submitHandler:function(form){
          if($("#pay_status").val()==1){
              alert('该会员已经发放门票,请检查');
          }else if($("#pay_status").val()==2) {
              alert('会员尚未注册,请检查');
          }else{
             // $("#post_form").submit();
              ajaxpost('post_form', '', '', 'onerror');
          }
    	},
        rules : {
            mobile : {
                required   : true
            }
        },
        messages : {
            mobile  : {
                required   : '<i class="icon-exclamation-sign"></i>手机号码不能为空'
            }
        }
    });
});
</script>
